/*
 *
 *过滤器
 */

import moment from 'moment'
import accounting from 'accounting'

export default {
  phoneFilter: function(val) {
    return val.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
  },
  strTonum: function(val) {
    return parseInt(val)
  },
  toFixed: function(val) {
    return accounting.toFixed(val, 2)
  },
  formatDate: function(value, formatString) {
    formatString = formatString || 'YYYY-MM-DD HH:mm:ss'
    return moment(value).format(formatString)
  }
}
